package tankgame3;

public class Shot implements Runnable{
    int x;
    int y;
    int direct;
    int speed=2;
    boolean isLive = true;


    public Shot(int x, int y, int direct) {
        this.x = x;
        this.y = y;
        this.direct = direct;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println(x+"--"+y);
            switch (direct) {
                case 0://上
                    y-=speed;
                    break;
                case 1://right
                    x+=speed;
                    break;
                case 2://down
                    y+=speed;
                    break;
                case 3://left
                    x-=speed;
                    break;
            }//switch
            if(!(x>=0 && x<=800 &&y>=0 &&y<=500)){//子弹不再框里
                isLive=false;
                break;
            }

        }//while
    } //run
}
